import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;              
import java.awt.event.*;       
import java.net.URL;
import java.io.*;
import java.lang.Object;
import java.util.Properties;
 
 
        //formatka wyboru formatu transmisji
	class AutoRepleyFrame extends JFrame{
		Properties wlasciwosci = PropertyLoader.load("conf/System.properties"); 		
                String ARString = wlasciwosci.getProperty("AUTO.REPLY");
                
                public AutoRepleyFrame(){
                  
                setTitle("Okna wyboru transmisji zwrotnej");
                setResizable(false);
                setSize(350,100);
                setLocation(260,0);
                JLabel text2 = new JLabel("Automatyczna transmisja zwrotna :");
                text2.setAlignmentX(CENTER_ALIGNMENT);
                getContentPane().add(text2,BorderLayout.CENTER);
                
                final JCheckBox AR1Box = new JCheckBox("TAK");
                final JCheckBox AR2Box = new JCheckBox("NIE");
            
                AR1Box.addActionListener(new ActionListener(){
                		
         public void actionPerformed(ActionEvent e){
                        AR1Box.updateUI();
                        if (AR1Box.isSelected()){
                        	AR2Box.setSelected(false);}
                        	 else AR2Box.setSelected(true);
                       try{
                        wlasciwosci.setProperty("AUTO.REPLY","TAK");
                        FileOutputStream os = new FileOutputStream("conf/System.properties");
                        wlasciwosci.store(os,"Zmiana ustawien");
                        }catch(FileNotFoundException fnfe){}
                          catch(IOException ioe){}
                        }
                        });
                
                
                
                AR2Box.addActionListener(new ActionListener(){
                
         public void actionPerformed(ActionEvent e){
                      AR2Box.updateUI(); //Aktualizacja stanu
                       try{
                        wlasciwosci.setProperty("AUTO.REPLY","NIE");
                        FileOutputStream os = new FileOutputStream("conf/System.properties");
                        wlasciwosci.store(os,"Zmiana ustawien");
                        }catch(FileNotFoundException fnfe){}
                          catch(IOException ioe){}
                      
                      //Wylaczania opcji wyboru jezeli zaznaczony
                        if (AR2Box.isSelected()==true){
                    	AR1Box.setSelected(false);	
                    	}
                    	else AR1Box.setSelected(true);
                        }
                        });
                
                
                AR2Box.isValid();      
                JPanel ARPanel = new JPanel();
                
               
                ARPanel.add(AR1Box);
                ARPanel.add(AR2Box);
                getContentPane().add(ARPanel,BorderLayout.SOUTH);
                
                    if (ARString.equals("TAK")){
                        AR1Box.setSelected(true);
                        }else{AR2Box.setSelected(true);
                        }
                }
	}
